﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using SqlserverHelper;
using System.Threading;

using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using OJ;
using DLLmySQL;

public partial class getDistSeller : System.Web.UI.Page
{
    public string strCnn = ConfigurationSettings.AppSettings["DataBaseString"];

    protected void Page_Load(object sender, EventArgs e)
    {

        string shop_code = "";
        if (Request.Form["shop_code"] != null && Request.Form["shop_code"].ToString().Trim() != "")
        {
            shop_code = Request.Form["shop_code"].ToString();
        }

        string stResult = f_getDistCashier(shop_code);
        Response.Write(stResult);
    }

    public string f_getDistCashier(string shop_code)
    {
        Define.retSellerList ret = new Define.retSellerList();


        try
        {

            string strQuery = "";
            strQuery = @"select username as seller_code, nick_name as  seller_name from dsh_user 
                         where 1=1 and user_identity =  '90' ";
            if (shop_code.Replace("全部", "") != "")
            {
                strQuery += " and shop_code like '%" + shop_code.Trim() + "%'";
            }
            DataTable DT = CmySQL.GetDataTbale(strCnn, strQuery);

            if (DT != null && DT.Rows.Count > 0)
            {
                List<Define.SellerList> L = new List<Define.SellerList>();

                Define.SellerList r1 = new Define.SellerList();

                r1.seller_code = "";
                r1.seller_name = "全部";

                L.Add(r1);

                for (int i = 0; i < DT.Rows.Count; i++)
                {
                    Define.SellerList r = new Define.SellerList();

                    r.seller_code = DT.Rows[i][0].ToString().Trim();
                    r.seller_name = DT.Rows[i][1].ToString().Trim();

                    L.Add(r);
                }
                ret.code = 200;
                ret.msg = "success";
                ret.data = L;
            }
            else
            {
                ret.code = 200;
                ret.msg = "无数据!";
                ret.data = null;
            }
        }
        catch
        {
            ret.code = 20000;
            ret.msg = "服务不可用";
            ret.data = null;
        }

        return Ojson.ObjectToJson(ret);
    }
}